/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package specifications;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.nodes.Tag;

/**
 *
 * @author Jason
 */
public class Count implements YamlObject<Count> {
    public static final Tag TAG = new Tag("!Count");
    private int amount;
    private String unit;
    private String metric;

    public Count(){}
    public Count(int amount, String unit, String metric){
        this.amount = amount;
        this.unit = unit;
        this.metric = metric;
    }
    @Override
    public void dump(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileWriter writer = new FileWriter(filename);
        writer.write(yaml.dumpAs(this, TAG, DumperOptions.FlowStyle.BLOCK));
        writer.close();
    }

    @Override
    public Count load(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileReader reader = new FileReader(filename);
        Count count = yaml.loadAs(reader, Count.class);
        reader.close();
        return count;
    }


    /**
     * @return the amount
     */
    public int getAmount() {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(int amount) {
        this.amount = amount;
    }

    /**
     * @return the unit
     */
    public String getUnit() {
        return unit;
    }

    /**
     * @param unit the unit to set
     */
    public void setUnit(String unit) {
        this.unit = unit;
    }

    /**
     * @return the metric
     */
    public String getMetric() {
        return metric;
    }

    /**
     * @param metric the metric to set
     */
    public void setMetric(String metric) {
        this.metric = metric;
    }
    
}
